/*
** mysh.h for minishell2 in /home/lingla_j/work/tutorat/env
** 
** Made by julien linglain
** Login   <lingla_j@epitech.net>
** 
** Started on  Tue Feb 28 18:06:40 2012 julien linglain
** Last update Fri Apr  6 11:49:59 2012 julien linglain
*/

#ifndef MYSH_H_
# define MYSH_H_

# define ENVSIZE	8
# define is_space(c) (c == ' ' || c == '\t')

typedef struct	s_node
{
  char		*key;
  char		*value;
  struct s_node	*next;
}		t_node;

typedef struct	s_list
{
  t_node	*start;
  t_node	*end;
  int		size;
}		t_list;

typedef struct	s_cmd
{
  char		*cmd;
  int		(*ptr_func)(int bc, char *s, char **bv, t_list *envi);
}		t_cmd;

typedef struct	s_stw
{
  int		i;
  int		j;
  int		wd;
  char		**tab;
}		t_stw;

int		xread(int fd, char *buff, int size);
int		my_putnbr(int nb);
char		*epur_str(char *str, int word, int len);
void		my_putchar(char c);
int		my_print(t_list *env);
int		my_strlen(char *s);
int		check_key(t_list *env, char *key, char *value);
int		check_space(char *s);
int		check_command(int bc, char **bv, char *s, t_list *envi);
char		*my_strdup(char *s);
int		my_add(t_list *env, char *key, char *value);
int		init_env(t_list *envi, char **env);
int		xwrite(int d, void *buf, int nbytes);
void		*xmalloc(unsigned int size);
void		my_putstr(char *str);
void		my_puterror(char *str);
int		delete_list_all(t_list *env);
int		delete_list_last(t_list *env);
int		delete_list(t_list *env);
char		*get_value(char *from);
char		*get_key(char *from);
char		*my_strcpy(char *from);
int		check_exception(t_list *env, char *key);
int		delete_middle_node(t_list *env, char *key);
int		delete_last_node(t_list *env, char *key);
int		delete_first_node(t_list *env);
int		check_node(t_list *env, char *key);
int		delete_node(t_list *env, char *key);
void		my_memset(char *buffer, int c, int size);
void		*xmalloc(unsigned int size);
int		my_env(int bc, char *s, char **bv, t_list *env);
int		b_exit(int bc, char *s, char **bv, t_list *env);
int		my_tablen(char **av);
int		my_strcmp(char *s1, char *s2);
char		*my_read();
int		my_strlen(char *str);
char		*my_strcat(char *str1, char *str2);
int		my_setenv(int ac, char *s, char **tab, t_list *env);
int		my_unsetenv(int ac, char *s, char **av, t_list *env);
void		getprompt(t_list *envi, char *user, char *host);
int		prompt(t_list *envi);
void		handle_sig(int signum);
int		check_exist_access(char *s);
void		cd_error(char *s);
char		*getvalue(t_list *env, char *key);
int		my_cd(int bc, char *s, char **bv, t_list *envi);
int		my_chdir(t_list *env, char *pwd, char *path);
char		*get_current_dir_name(void);
char		*make_path(char *s, char *pwd);
int		free_bv(int bc, char **bv);
int		b_pwd(int ac, char *s, char **av, t_list *env);
char		*gohome(t_list *env);
char		*goback(t_list *env, char *pwd);
char		*cd_with_var(t_list *env, char *var, char *pwd);
char		*get_var(char *var);
void		boucle(t_list *envi, char *s, int bc, char **bv);
int		exec_com(int ac, char **av, char *s, t_list *env);
int		count_path(char *path, char sep);
int		my_exec(char *bin_path, char **av);
int		my_echokey(char *s, t_list *env, int i);
int		my_echo(char *s, t_list *env);
int		b_echo(int ac, char *s, char **av, t_list *env);
int		my_print_value(char *key, t_list *env);
int		check_if_path(char *s);
int		my_path_var_empty();
int		my_exec_with_path(char **av);
int		countword3(char *s, int i, int j);
int		countword2(char *s);
int		countword(char *s);
void		show_tab(char **tab, int wd);
void		str_to_wordtab3(t_stw *var, char *s);
void		str_to_wordtab2(t_stw *var, char *s);
char		**str_to_wordtab(char *s, int len);
int		check_quote(char *s);
char		**my_str_to_wordtab(char *s);

#endif /* MYSH_H_ */
